package d1_exception;

import java.util.Scanner;

public class ExceptionDemo06 {
    public static void main(String[] args) {
        //目标: 异常的处理方式2: 捕获异常, 尝试修复
        while (true) {
            try {
                double price = getPrice();
                System.out.println("本商品定价是: " + price);
            } catch (Exception e) {
                System.out.println("您输入的价格是不对");
            }
        }
    }

    public static double getPrice() {
        Scanner sc = new Scanner(System.in);
        System.out.println("请您输入一个合法的价格：");
        double price = sc.nextDouble();
        return price;
    }
}
